﻿using System.Web;

namespace TSharp.Core.Authentication.Facade
{
    /// <summary>
    /// 身份验证服务
    /// <para>2010/7/12</para>
    /// 	<para>TANGJINGBO</para>
    /// 	<para>tangjingbo</para>
    /// </summary>
    public interface IAuthenticationService
    {
        /// <summary>
        /// 获取当前登录用户
        /// <para>by tangjingbo at 2010/7/7 11:43</para>
        /// </summary>
        /// <returns></returns>
        IUser GetLoginUser(HttpContextBase context);


        /// <summary>
        /// 生成登录令牌
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="key">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <param name="createPersistentCookie">if set to <c>true</c> [create persistent cookie].</param>
        /// <returns></returns>
        IUser SignIn(HttpContextBase context, string key, string password, bool createPersistentCookie);

        /// <summary>
        /// 清除登录令牌，退出登录
        /// </summary>
        void SignOut(HttpContextBase context);

        /// <summary>
        /// 验证上下文是否已经过验证
        /// </summary>
        /// <param name="ContextBase">The context base.</param>
        /// <returns>
        /// 	<c>true</c> if the specified context base is authenticated; otherwise, <c>false</c>.
        /// </returns>
        bool IsAuthenticated(HttpContextBase ContextBase);

        /// <summary>
        /// 转到导致重定向到登录页的原始请求的重定向 URL。
        /// </summary>
        /// <param name="ContextBase">The context base.</param>
        void RedirectUrl(HttpContextBase ContextBase);


        /// <summary>
        /// 验证当前上下文是否已经过验证，如果验证成功则转到导致重定向到登录页的原始请求的重定向 URL。
        /// </summary>
        /// <param name="ContextBase">The context base.</param>
        void IsAuthenticatedAndRedirectUrl(HttpContextBase ContextBase);
    }
}